
package com.joysuch.wwyt.bp.enums;

/**
 * 变更类型
 */
public enum ChangeRecordType {

    USER("User", "人员管理") ,
    USER_CERTIFICATE("UserCertificate", "资质证件") ,
    DEVICE("Device", "生产装置") ,
    MANUFACT_TECH("ManufactTech", "工艺流程") ,
    STORAGE_TANK("StorageTank", "储罐"),
    STORAGE_TANK_AREA("StorageTankArea", "储罐区"),
    MONITOR_POINT("MonitorPoint", "监测点");


    private String code;
    private String name;

    private ChangeRecordType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public static ChangeRecordType findByName(String name) {
        ChangeRecordType[] values = ChangeRecordType.values();
        for (ChangeRecordType v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static ChangeRecordType findByCode(String code) {
        ChangeRecordType[] values = ChangeRecordType.values();
        for (ChangeRecordType v : values) {
            if (v.getCode().equals(code)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameByCode(String code) {
        ChangeRecordType types = findByCode(code);
        return types == null ? null : types.name;
    }
}
